package com.jolink.omiis.wechat.outer;

import com.jolink.omiis.wechat.crypt.aes.AesException;
import com.jolink.omiis.wechat.crypt.aes.WXBizMsgCrypt;
import com.jolink.omiis.wechat.message.type.UserType;

public class Crypt implements ICrypt {

	private WXBizMsgCrypt wxBizMsgCrypt = null;

	public Crypt(String token, String encodingAesKey, String appId) throws AesException {
		wxBizMsgCrypt = new WXBizMsgCrypt(token, encodingAesKey, appId);
	}

	@Override
	public String encrypt(String replyMsg, String timeStamp, String nonce) throws AesException {
		return wxBizMsgCrypt.encryptMsg(replyMsg, timeStamp, nonce);
	}

	@Override
	public String decrypt(String msgSignature, String timeStamp, String nonce, String postData, UserType mt2)
			throws AesException {
		return wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData,mt2);
	}

	@Override
	public String verifyMsgValid(String msgSignature, String timeStamp, String nonce, String echoStr)
			throws AesException {
		return wxBizMsgCrypt.verifyUrl(msgSignature, timeStamp, nonce, echoStr);
	}

}
